
const logger = require('../../../log')('user');
const userService = require('../service/UserService');
const Result = require('../../../utils/Result');
const {wrap: async} = require('co');

/**
 * 用户信息
 */
exports.list = async(function*(req, res, next) {
    try {
        let data = yield userService.list({})
        return Result.ok(res, data);
      } catch (err) {
        return Result.error(res, err);
      }
});

/**
 * 保存
 */
exports.save = async(function*(req, res, next) {
    let user = req.body;
    userService.save(user, function(err, data) {
        if (err) {
        logger.error('user save error: ', err);
        return Result.error(res, err);
        }
        return Result.ok(res, data);
    });
})